'''摄像头展示模块'''
import time

import cv2
from configs import parse_args
class ShowCamare:
    def __init__(self,stereovison, show_interval: int = 0.03):
        self.ready=False
        self.stereovison = stereovison
        self.args = parse_args()
        self.edge = self.args.max_vision_edge
        self.show_interval = show_interval
        pass

    def show(self):
        while True:
            time.sleep(self.show_interval)
            if self.stereovison.img is not None:
                cv2.rectangle(self.stereovison.img, (self.edge[0], self.edge[1]), (self.edge[2],self.edge[3]), (255, 0, 0),3)
                if self.stereovison.img_draw_finish:#
                    cv2.namedWindow("camera",cv2.WINDOW_NORMAL)
                    # print(stereovison.img)
                    cv2.imshow('camera', self.stereovison.img)
            ch = cv2.waitKey(1)
            if ch == 27 or ch == ord('q') or ch == ord('Q'):
                break